/*
    Meter JMX Utility Library
    Copyright (C) 2005  Noah Campbell

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
package info.noahcampbell.meter;


import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Logger;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

/**
 * @author Noah Campbell
 * @version 1.0
 */
public class Meter implements Metric {
    
    /** The statisticsQueue. */
    private Queue<Number> statisticsQueue = new ConcurrentLinkedQueue<Number>(); 
    
    /**
     * Construct a new <code>Meter</code>.
     */
    Meter() {
        super();
    }
    
    /** The logger. */
    private static final Logger logger = Logger.getLogger("METER");
    
    /**
     * @see Metric#getStatisticsQueue()
     */
    public Queue<Number> getStatisticsQueue() {
        return this.statisticsQueue;
    }
    
    /**
     * @see Metric#attachQueue(java.util.Queue)
     */
    @Deprecated
    public void attachQueue(Queue<Number> q) {
        this.statisticsQueue = q;
    }
    
    
    /** The start time in ms. */
    private long start;
    
    
    /**
     * Start time
     */
    public void start() {
       start(System.currentTimeMillis());
    }
    
    public void start(long time) {
        start = time;
    }
    
    public void stop() {
        this.statisticsQueue.add(System.currentTimeMillis() - start);
    }

}
